{% extends "personnel/base.html" %}

{% block page_link %}
    <link rel="stylesheet" href="../../static/system_setup/css/style.css">
    <link rel="stylesheet" type="text/css" href="../../static/personal_center/css/index.css">
    <link rel="stylesheet" type="text/css" href="../../static/personal_center/css/common.css">
    <script type="text/javascript" src="../../static/personal_center/js/index.js"></script>
    <link type="text/css" rel="stylesheet" href="../../static/personnel/TimeSelector/skin/jedate.css">
    <script type="text/javascript" src="../../static/personnel/TimeSelector/src/jedate.js"></script>
    <script type="text/javascript" src="../../static/public_file/js/ModalBox.js"></script>
{% endblock %}

{% block style %}
    <style>
        .add_class {
            background: #1E90FF;
        }
        .add_background {
            background: #A9A9A9;
        }
        .li-class {
            list-style: none;margin-top: 2%;color: #0b0b0b;cursor: pointer;
        }
        .shade {
            position: fixed;top: 0;left: 0;right: 0;bottom: 0;width: 100%;height: 100%;background-color: rgba(36, 36, 36, 0.5);display: none;z-index: 10;
        }
        .file {
            position: relative;display: inline-block;background: #D0EEFF;border: 1px solid #99D3F5;border-radius: 4px;padding: 4px 12px;overflow: hidden;color: #1E88C7;text-decoration: none;text-indent: 0;line-height: 20px;letter-spacing:0px;
        }
        .file input {
            position: absolute;font-size: 100px;right: 0;top: 0;opacity: 0;
        }
        .file:hover {
            background: #AADFFD;border-color: #78C3F3;color: #004974;text-decoration: none;
        }
        #addForm {
            width: 800px;height: 620px;background: #F5F5F5;position: absolute;border: #dfdfdf solid 1px;margin: auto;border-radius: 3px;top: 50%;left: 50%;transform: translate(-50%, -50%);display: none;z-index: 10100;font-size: 0;
        }
        #title {
            display: flex;justify-content: space-between;box-sizing: border-box;padding: 0 10px;height: 50px;color: #0b0b0b;cursor: move;width: 100%;background: #f4f7fa;border-top-left-radius: 5px;border-top-right-radius: 5px;
        }
        .search {
            width: 300px;display: flex;float: right;margin: 10px 0;margin-right: 1%;
        }
        .search input {
            vertical-align: middle;float: left;flex: 4;height: 30px;width: 230px;outline: none;border: 1px solid #0070c1;box-sizing: border-box;border-bottom-left-radius: 3px;border-top-left-radius: 3px;
        }
        .search button {
            float: right;flex: 1;height: 30px;width: 70px;line-height: 30px;background-color: #0070c1;color: white;border-style: none;outline: none;border-bottom-right-radius: 3px;border-top-right-radius: 3px;
        }
        .search button i {
            font-style: normal;
        }
        .search button:hover {
            font-size: 16px;
        }
        .PreScheduling {
            width: 100px;height: 30px;margin-top: 8px;border: #00A680 solid 1px;background: #00A680;color: white;border-radius: 3px;letter-spacing: 5px;
        }
        .PreScheduling:hover {
            background: #0d7862;border: #0d7862 solid 1px;
        }
        .confirm {
            width: 100px;height: 30px;margin-top: 8px;border: #00a0e9 solid 1px;background: #00a0e9;color: white;border-radius: 3px;letter-spacing: 5px;margin-left: 10px;
        }
        .confirm:hover {
            background: #1266f1;border: #1266f1 solid 1px;
        }
        .cancel {
            width: 100px;height: 30px;margin-top: 8px;border: #DFDFDF solid 1px;background: #DFDFDF;border-radius: 3px;letter-spacing: 5px;margin-left: 10px;
        }
        .cancel:hover {
            background: #cfcfcf;border: #cfcfcf solid 1px;
        }
        .scheduling-data {
            width: 100%;border-bottom: #CCCCCC solid 1px;height: 40px;font-size: 0;margin: 0;padding: 0;
        }
        .scheduling-data:hover {
            background: #F5F5F5;
        }
        #SchedulingData {
            width: 100%;height: 475px;overflow: auto;
        }
        ::-webkit-scrollbar {
          width: 4px;
        }
    </style>
{% endblock %}


{% block right_content %}
    <div id="new_models2" class="shade">
        <div id="add_personnel1" style="position: absolute;width: 800px;height: 600px;top: 20%;left: 35%;box-shadow: 0 0 4px #999;background: white;border-radius: 3px;">
            <div id="box1" style="width: 100%;height: 40px;border-bottom: #cfcfcf solid 1px;line-height: 40px;padding-left: 10px;cursor: move;">
                <p style="display: inline-block;">预排班</p>
                <p onclick="close_model2()" style="display: inline-block;float: right;cursor: pointer;width: 35px;height: 35px;line-height: 35px;text-align: center;">
                    <i class="iconfont icon-quchu"></i>
                </p>
            </div>

            <div style="width: 100%;height: 515px;">
                <div style="width: 100%;">
                    <div style="width: 100%;border-bottom: #CCCCCC solid 1px;background: #F5F5F5;font-size: 0;margin: 0;padding: 0;">
                        <div style="width: 184px;height: 40px;border-right: #CCCCCC solid 1px;text-align: center;display: inline-block;vertical-align: top;line-height: 40px;font-size: 14px;">日期</div>
                        <div style="width: 120px;height: 40px;border-right: #CCCCCC solid 1px;text-align: center;display: inline-block;vertical-align: top;line-height: 40px;font-size: 14px;">类型</div>
                        <div style="width: 240px;height: 40px;border-right: #CCCCCC solid 1px;text-align: center;display: inline-block;vertical-align: top;line-height: 40px;font-size: 14px;">一线班</div>
                        <div style="width: 240px;height: 40px;text-align: center;display: inline-block;vertical-align: top;line-height: 40px;font-size: 14px;">二线班</div>
                    </div>
                    <div id="SchedulingData">
                        <div id="SchedulingPictures" style="width: 30%;height: 30%;margin-top: 18%;margin-left: 30%;text-align: center;">
                            <img src="../../static/personal_center/img/暂无资源.png" alt="" style="width: 120px;height: 120px;margin-top: 30px;">
                            <p style="color: #cfcfcf;">请点击预排班</p>
                        </div>
                    </div>
                </div>
            </div>

            <div style="width: 100%;height: 40px;text-align: center;">
                <button onclick="OnclickPreScheduling('pre_scheduling')" class="PreScheduling">预排班</button>
                <button onclick="OnclickPreScheduling('scheduling')" class="confirm">确认</button>
                <button onclick="close_model2()" class="cancel">取消</button>
            </div>
        </div>
    </div>

    <div id="new_models1" class="shade">
        <div id="add_personnel" style="position: absolute;width: 400px;height: 250px;top: 25%;left: 45%;box-shadow: 0 0 4px #999;background: white;border-radius: 3px;">
            <div id="box" style="width: 100%;height: 35px;border-bottom: #cfcfcf solid 1px;line-height: 35px;padding-left: 10px;cursor: move;">
                <p style="display: inline-block;">修改排班数据</p>
                <p onclick="close_model()" style="display: inline-block;float: right;cursor: pointer;width: 35px;height: 35px;line-height: 35px;text-align: center;">
                    <i class="iconfont icon-quchu"></i>
                </p>
            </div>
            <div style="width: 100%;height: 170px;border-bottom: #cfcfcf solid 1px;padding: 20px;">
                <div style="width: 100%;height: 40px;line-height: 40px;">
                    <label for="">选择人员：</label>
                    <input type="text" style="width: 250px;height: 30px;border: #cfcfcf solid 1px;border-radius: 3px;" onclick="fill_val()" id="conferee">
                </div>
            </div>

            <div style="width: 100%;height: 45px;text-align: right;padding-right: 10px;">
                <button id="save_but" style="width: 70px;height: 29px;margin-top: 8px;border: #00a0e9 solid 1px;background: #00a0e9;color: white;border-radius: 3px;">保存</button>
            </div>
        </div>
    </div>

    <div style="display: inline-block;vertical-align: top;width: 100%;height: 99%;margin-top: 5px;">
        <div class="headline">
            <div style="display: inline-block;vertical-align: top;margin-left: 5px;margin-top: 3px;">
                <label style="margin-left: 10px;">班次：</label>
                <div type="text" style="width: 200px;height: 30px;display: inline-block;" id="shift">
                    <select name="" id="duty_Shift" style="border: #cfcfcf solid 1px;border-radius: 3px;width: 200px;height: 30px;">
                        <option value="">选择班次</option>
                        <option value="1">一线班</option>
                        <option value="2">二线班</option>
                    </select>
                </div>

                <label style="margin-left: 10px;">时间：</label>
                <input type="text" style="width: 200px;height: 30px;border: #cfcfcf solid 1px;border-radius: 3px;display: inline-block;" id="test08" placeholder="选择时间段">

                <div class="sa-ele" style="display: inline-block;vertical-align: top;margin-left: 10px;">
                    <label>姓名：</label><input class="se-con" name="user" placeholder="输入姓名" style="width: 200px;height: 30px;border-radius: 3px;border: #cfcfcf solid 1px;">
                </div>
                <div class="sa-ele" style="width: 70px;display: inline-block;vertical-align: top;">
                    <button class="search-action" style="width: 100%;height: 30px;border-radius: 3px;border: #cfcfcf solid 1px;">搜索
                    </button>
                </div>
            </div>

            <div style="width: 235px;float: right;padding-right: 10px;text-align: right;">
                <button onclick="add_people()" style="width: 100px;height: 28px;margin-top: 6px;border-radius: 3px;background: green;border: green solid 1px;color: white;">预排班</button>


            <button style="width: 100px;height: 28px;margin-top: 6px;border-radius: 3px;background: green;border: green solid 1px;color: white;"
                    onmousemove="page_zhanshi()" onmouseout="page_yincang()">Excel导入
            </button>
            </div>
            <div id="page_one" style="z-index: 1000; position: absolute; width: 100px; height: 85px;right: 0.5%; top: 84px;background: #FFFFFF; box-shadow: rgb(204 204 204) 2px 2px 10px;padding: 5px;display: none;"
                 onmousemove="page_zhanshi()" onmouseout="page_yincang()">
                <div style="margin-bottom: 10px;">
                    <a href="javascript:;" class="file" style="vertical-align: top;">
                        Excel导入
                        <input type="file" name="party_main_body" id="party_main_body"
                               onchange="upload_accessory('file1', 'party_main_body')">
                    </a>
                </div>
                <div>
                    <a href="../../static/personnel/京山医院人事排班模板.xlsx" download="京山医院人事排班模板.xlsx" style="vertical-align: top;border: 1px solid #99D3F5; background: #D0EEFF; border-radius: 4px; padding: 4px 15.5px;letter-spacing:0;">模板下载</a>
                </div>
            </div>
        </div>
        <div id="my_application" style="width: 100%;height: 95.3%;overflow: auto;background-color: white;">
            <div class="right-box" style="width: 100%;height: 100%;margin-top: 0;">
                <div style="height: 100%;width: 100%;overflow: auto;border-bottom: #cccccc solid 1px;background-color: white;">
                    <section class="grid-main" style="height: 100%;">
                        <table id="main_table"></table>
                    </section>
                </div>
            </div>
        </div>
        <div id="addForm">
            <!-- 标题 -->
            <div id="title">
                <h5 style="line-height: 50px;width: 15%;margin-left: 1%;display: inline-block;font-size: 18px;">选择值班人员</h5>
                <div class="search" style="vertical-align: center;display: inline-block;text-align: right;margin-left: 35%;font-size: 14px;">
                    <input type="text" placeholder="请输入..." name="" id="search_data" value="">
                    <button id="search_button">搜索</button>
                </div>
                <span onclick="close_models1()" style="float: right;line-height: 50px;padding-right: 2%;cursor: pointer;"><i class="iconfont icon-quchu"></i></span>
            </div>
            <hr>
            <div style="display: inline-block;width: 30%;height: 350px;border-right: #E8E8E8 solid 1px;">
                <div style="width: 100%;height: 35px;line-height: 35px;padding-left: 2%;color: #0b0b0b;border-bottom: #cfcfcf solid 1px;font-size: 14px;">
                    <div id="an_branch"
                         style="width: 31.5%;display: inline-block;cursor: pointer;text-align: center;color: #01aaed;">
                        按部门
                    </div>
                    <div id="an_rank"
                         style="width: 31.5%;display: inline-block;cursor: pointer;text-align: center;">按权限
                    </div>
                    <div id="an_func"
                         style="width: 31.5%;display: inline-block;cursor: pointer;text-align: center;">按职能
                    </div>
                </div>
                <div id="department_list" style="width: 100%;height: 315px;overflow: auto;">
                    <div style="width: 100%;height: 100%;text-align: center;">
                        <img style="width: 30%;height: 30%;margin-top: 35%;"
                             src="../../static/public_file/images/jiazai.gif" alt="">
                    </div>
                </div>
            </div>

            <div style="display: inline-block;width: 69.5%;height: 350px;overflow: auto;vertical-align: top;left: 0;font-size: 14px;">
                <table class="table table-hover table-bordered"
                       style="border-collapse: collapse;margin: 0;padding: 0;">
                    <thead>
                    <tr>
                        <th scope="col" style="width: 10%;text-align: center;">
                            <input id="all_select_checkbox" type="checkbox">
                        </th>
                        <th scope="col" style="width: 20%;text-align: center;">序号</th>
                        <th scope="col" style="width: 35%;text-align: center;">姓名</th>
                        <th scope="col" style="width: 35%;text-align: center;">工号</th>
                    </tr>
                    </thead>
                    <tbody style="overflow: auto;" id="t_table2"></tbody>
                </table>
                <div id="img-display1" style="width: 75%;text-align: center;">
                    <div style="margin-top: 10%;">
                        <img src="../../static/public_file/images/page-img/11.jpg" alt="">
                        <p style="margin: 0;padding: 0;vertical-align: top;">暂无数据</p>
                    </div>
                </div>
            </div>

            <div style="height: 150px;width: 100%;border-top: #E8E8E8 solid 1px;overflow: auto;">
                <div id="checked-label" style="margin-top: 1%;margin-left: 3%;width: 90%;font-size: 14px;">

                </div>
            </div>
            <hr>
            <div style="height: 70px;padding-right: 2%;font-size: 14px;">
                <button onclick="choose_people()" id="model-affirm" style="border-radius: 3px;height: 30px;float: right;margin-top: 15px;border: #1E90FF solid 1px;background: #1E90FF;color: white;">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;提&nbsp;交&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </button>
            </div>
        </div>
    </div>
{% endblock %}

{% block script %}
    <script type="text/javascript" src="../../static/personnel/TimeSelector/test/demo.js"></script>
    <script>
        window.onload = function () {
            document.getElementById("loading").style.display = "none";
            document.getElementById("attendance").className = "add_class";
            document.getElementById("SystemScheduling").className = "add-nav-active";
        };

        let title = document.querySelector("#box");
        let addForm = document.querySelector("#add_personnel");
        const fj_number= "{{ uuid | safe }}"

        title.addEventListener("mousedown", function (e) {
            let x = e.pageX - addForm.offsetLeft;
            let y = e.pageY - addForm.offsetTop;

            document.addEventListener("mousemove", move);
            function move(e) {
                addForm.style.left = e.pageX - x + 'px';
                addForm.style.top = e.pageY - y + 'px';
            }

            document.addEventListener("mouseup", function (e) {
                document.removeEventListener("mousemove", move);
            })
        });

        let title1 = document.querySelector("#box1");
        let addForm1 = document.querySelector("#add_personnel1");

        title1.addEventListener("mousedown", function (e) {
            let x = e.pageX - addForm1.offsetLeft;
            let y = e.pageY - addForm1.offsetTop;

            document.addEventListener("mousemove", move);
            function move(e) {
                addForm1.style.left = e.pageX - x + 'px';
                addForm1.style.top = e.pageY - y + 'px';
            }

            document.addEventListener("mouseup", function (e) {
                document.removeEventListener("mousemove", move);
            })
        });

        function page_zhanshi() {
            document.getElementById('page_one').style.display = 'inline-block';
        }

        function page_yincang() {
            document.getElementById('page_one').style.display = 'none';
        }

        function upload_accessory(file_type, accessory_type) {
            document.getElementById("loading").style.display = "inline-block";
            var form = new FormData();
            var files = document.getElementById(accessory_type).files[0];
            form.append(file_type, files);
            form.append('number', fj_number)
            form.append('source', 'rspb')     // 请假流程
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/administrative/topics_attachments_upload", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        var form1 = new FormData();
                        form1.append(file_type, files);
                        form1.append("fj_number", fj_number)
                        var xhr1 = new XMLHttpRequest();
                        var local_host1 = window.location.host;          // 获取当前IP
                        xhr1.open('post', "/personnel/upload_excel", true);
                        xhr1.send(form1);
                        xhr1.onreadystatechange = function () {
                            if (xhr1.readyState === 4) {
                                if (xhr1.status === 200) {
                                    document.getElementById("loading").style.display = "none";
                                    var JsonDate = JSON.parse(xhr1.responseText);
                                    alert(JsonDate["message"])
                                    window.location.href = "/personnel/system_scheduling.html"
                                    document.getElementById("party_main_body").value = "";
                                }
                            }
                        };
                    }
                }
            };
        }

        const gridManagerName = "test",
        TYPE_MAP = {1: "HTML/CSS", 2: "nodeJS", 3: "javaScript", 4: "前端鸡汤", 5: "PM Coffee", 6: "前端框架", 7: "前端相关"},
        GM_PUBLISH_METHOD_MAP = {
            init: {key: "init", relyInit: !1, title: "初始化", code: 'demo1.initGM(document.querySelector("table"));'},
            get: {key: "get", relyInit: !0, title: "获取表格的实时配置信息", code: `GridManager.get('${gridManagerName}');`},
            version: {key: "version", relyInit: !1, title: "获取当前GridManager的版本号", code: "GridManager.version;"},
            getLocalStorage: {
                key: "getLocalStorage",
                relyInit: !0,
                title: "获取表格用户记忆",
                code: `GridManager.getLocalStorage('${gridManagerName}');`
            },
            resetLayout: {
                key: "resetLayout",
                relyInit: !0,
                title: "重置表格布局",
                code: `GridManager.resetLayout('${gridManagerName}', '800px', '500px');`
            },
            clear: {
                key: "clear",
                relyInit: !0,
                title: "清除表格记忆数据",
                code: `GridManager.clear('${gridManagerName}');`
            },
            getTableData: {
                key: "getTableData",
                relyInit: !0,
                title: "获取指定tr所使用的数据",
                code: `GridManager.getTableData('${gridManagerName}');`
            },
            getRowData: {
                key: "getRowData",
                relyInit: !0,
                title: "获取指定tr所使用的数据",
                code: `GridManager.getRowData('${gridManagerName}', document.querySelector("table[grid-manager=${gridManagerName}] tbody tr"));`
            },
            updateRowData: {
                key: "updateRowData",
                relyInit: !0,
                title: "更新指定行所使用的数据",
                code: `GridManager.updateRowData('${gridManagerName}', 'id', {id: 112, title: 'ccc'});`
            },
            updateTreeState: {
                key: "updateTreeState",
                relyInit: !0,
                title: "更新树的展开状态",
                code: `GridManager.updateTreeState('${gridManagerName}', true);`
            },
            setSort: {
                key: "setSort",
                relyInit: !0,
                title: "手动设置排序",
                code: `GridManager.setSort('${gridManagerName}', {createDate: 'ASC'});`
            },
            setConfigVisible: {
                key: "setConfigVisible",
                relyInit: !0,
                title: "设置表头配置区域可视状态",
                code: `GridManager.setConfigVisible('${gridManagerName}', true);`
            },
            setLineHeight: {
                key: "setLineHeight",
                relyInit: !0,
                title: "配置行的高度",
                code: `GridManager.setLineHeight('${gridManagerName}', '70px');`
            },
            showTh: {
                key: "showTh",
                relyInit: !0,
                title: "设置列为可视状态",
                code: `GridManager.showTh('${gridManagerName}', 'pic');`
            },
            hideTh: {
                key: "hideTh",
                relyInit: !0,
                title: "设置列为隐藏状态",
                code: `GridManager.hideTh('${gridManagerName}', 'pic');`
            },
            exportGrid: {
                key: "exportGrid",
                relyInit: !0,
                title: "导出指定表格",
                code: `GridManager.exportGrid('${gridManagerName}', 'demo中使用的导出').then(res=>{console.log('success')}).catch(err=>{console.error('error', err)});`
            },
            setQuery: {
                key: "setQuery",
                relyInit: !0,
                title: "更改在生成组件时所配置的参数query",
                code: `GridManager.setQuery('${gridManagerName}', {'userName':'baukh','sex':'男'});`
            },
            setAjaxData: {
                key: "setAjaxData",
                relyInit: !0,
                title: "用于再次配置ajaxData数据",
                code: `GridManager.setAjaxData('${gridManagerName}', {data: [{title: '通过setAjaxData动态添加的数据，其它项为空'}], totals: 1});`
            },
            refreshGrid: {
                key: "refreshGrid",
                relyInit: !0,
                title: "刷新表格",
                code: `GridManager.refreshGrid('${gridManagerName}');`
            },
            renderGrid: {
                key: "renderGrid",
                relyInit: !0,
                title: "渲染表格",
                code: `GridManager.renderGrid('${gridManagerName}');`
            },
            getCheckedTr: {
                key: "getCheckedTr",
                relyInit: !0,
                title: "获取当前选中的行",
                code: `GridManager.getCheckedTr('${gridManagerName}');`
            },
            getCheckedData: {
                key: "getCheckedData",
                relyInit: !0,
                title: "获取选中行的渲染数据",
                code: `GridManager.getCheckedData('${gridManagerName}');`
            },
            setCheckedData: {
                key: "setCheckedData",
                relyInit: !0,
                title: "设置选中的数据",
                code: `GridManager.setCheckedData('${gridManagerName}', [GridManager.getTableData('${gridManagerName}')[1]]);`
            },
            cleanData: {
                key: "cleanData",
                relyInit: !0,
                title: "清除指定表格数据",
                code: `GridManager.cleanData('${gridManagerName}');`
            },
            print: {key: "print", relyInit: !0, title: "打印当前页", code: `GridManager.print('${gridManagerName}');`},
            showRow: {
                key: "showRow",
                relyInit: !0,
                title: "显示隐藏行",
                code: `GridManager.showRow('${gridManagerName}', 1);`
            },
            hideRow: {
                key: "hideRow",
                relyInit: !0,
                title: "隐藏行",
                code: `GridManager.hideRow('${gridManagerName}', 1);`
            },
            showLoading: {
                key: "showLoading",
                relyInit: !0,
                title: "显示加载中",
                code: `GridManager.showLoading('${gridManagerName}');`
            },
            hideLoading: {
                key: "hideLoading",
                relyInit: !0,
                title: "隐藏加载中",
                code: `GridManager.hideLoading('${gridManagerName}', 300);`
            },
            destroy: {
                key: "destroy",
                relyInit: !0,
                title: "消毁指定的GridManager实例",
                code: `GridManager.destroy('${gridManagerName}');`
            }
        }, arg = {
            gridManagerName: "test",
            width: "100%",
            height: "100%",
            autoOrderConfig: {fixed: "left"},
            checkboxConfig: {key: "id", fixed: "left"},
            supportAjaxPage: !0,
            sortMode: "single",
            supportMenu: !0,
            menuHandler: e => (e.unshift({
                content: "自定义菜单", line: !0, onClick: e => {
                    alert(e)
                }
            }), e),
            useCellFocus: !0,
            useHideRow: !0,
            supportMoveRow: !0,
            moveRowConfig: {
                key: "priority", useSingleMode: !0, fixed: "left", handler: (e, t) => {
                    console.log(e, t)
                }
            },
            disableCache: !1,
            ajaxData: function (e, t) {
                var local_host = window.location.host;          // 获取当前IP
                return "/personnel/system_scheduling.html"
            },
            exportConfig: {
                fileName: e => {
                    const t = new Date;
                    let a = `${t.getFullYear()}-${t.getMonth() + 1}-${t.getDate()}`;
                    for (let t in e) a = `${a}-${t}=${e[t]}`;
                    return a
                }, suffix: "xls"
            },
            ajaxType: "POST",
            checkedBefore: function (e, t, a) {
                return console.log("checkedBefore==", e, t, a), a && 90 === a.id && alert("该节点在checkedBefore中配置为不可选"), a && 90 !== a.id
            },
            checkedAfter: function (e, t, a) {
                console.log("checkedAfter==", e, t, a)
            },
            checkedAllBefore: function (e, t) {
                console.log("checkedAllBefore==", e, t)
            },
            checkedAllAfter: function (e, t) {
                console.log("checkedAllAfter==", e, t)

            },
            sortingBefore: function (e) {
                console.log("sortingBefore", e)
            },
            sortingAfter: function (e) {
                console.log("sortingAfter", e)
            },
            ajaxBeforeSend: function (e) {
                console.log("ajaxBeforeSend")
            },
            ajaxSuccess: function (e) {
                console.log("ajaxSuccess")
            },
            ajaxError: function (e) {
                console.log("ajaxError")
            },
            ajaxComplete: function (e) {
                console.log("ajaxComplete")
            },
            adjustBefore: e => {
                console.log("adjustBefore=>", e)
            },
            adjustAfter: e => {
                console.log("adjustAfter=>", e)
            },
            responseHandler: e => (e.data.forEach((e => {
                e.priority = e.id
            })), e),
            rowRenderHandler: (e, t) => e,
            emptyTemplate: e => `<div style="text-align: center;">${e.query.title ? "搜索为空" : "暂无数据"}</div>`,
            columnData: [
                {
                    key: "Shift",
                    text: "班次",
                    align: "center",
                    disableMoveRow: !0
                }, {
                    key: "name",
                    text: "值班人",
                    align: "left",
                }, {
                    key: "duty_time",
                    text: "值班时间",
                    align: "center",
                }, {
                    key: "shift_arrangement",
                    text: "值班类型",
                    align: "center",
                }, {
                    key: "action",
                    width: "100px",
                    align: "center",
                    fixed: "right",
                    disableMoveRow: !0,
                    disableRowCheck: !0,
                    text: '<span style="color: red">操作</span>',
                    template: (e, t) => `<a class="plugin-action" id="${t.id}" href="javascript:;">${t.url}</a>`
                }]
        }, demo1 = {
                initSearch: function () {
                    document.querySelector(".search-action").addEventListener("click", (function () {
                        var myselect = document.getElementById("duty_Shift");
                        var index = myselect.selectedIndex ;                  // selectedIndex代表的是你所选中项的index
                        var duty_Shift = myselect.options[index].value;     // 选择班次
                        var e = {
                            names: document.querySelector('[name="user"]').value,
                            dech_time: document.getElementById("test08").value,
                            duty_Shift: duty_Shift,
                        };
                        table.GM("setQuery", e, (function () {
                            console.log("setQuery执行成功````````````````", e)
                        }))

                    }))
                }, initFN: () => {

                }, initGM: function () {
                    new window.GridManager(table, arg, (e => {
                        console.log("渲染完成后的回调函数:", e), console.log(arg.columnData)
                    }))
                }, editRowData: function (e) {
                    window.GridManager.updateRowData("test", "id", {
                        id: window.parseInt(e.getAttribute("data-id")),
                        lastDate: (new Date).getTime()
                    })
                }
            }, table = document.querySelector("table");
        demo1.initSearch(table), demo1.initGM(table), demo1.initFN();


        function add_people() {
            document.getElementById("new_models2").style.display="table";
        }

        function close_model() {
            document.getElementById("new_models1").style.display="none";
        }

        function change_person_data(ids) {
            document.getElementById("new_models1").style.display="table";
            document.getElementById('save_but').setAttribute('onclick', 'save_val("'+ids+'")')
        }

        function close_model2() {
            document.getElementById("new_models2").style.display="none";
        }

        function OnclickPreScheduling(scheduling_type) {
            document.getElementById("loading").style.display = "'inline-block'";
            document.getElementById("SchedulingData").innerHTML = "";
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/personnel/click_on_pre_scheduling", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("type="+scheduling_type);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate)
                        if (JsonDate["code"] === 200) {
                            if (scheduling_type === 'scheduling') {
                                alert(JsonDate["message"]);
                                window.location.reload();
                            }
                            for (var i=0; i<JsonDate["data"].length; i++) {
                                if (JsonDate["data"][i]["Judgment"] === 1) {
                                    console.log(JsonDate["data"][i]["Judgment"])
                                    var html_str = `
                                            <div class="scheduling-data">
                                            <div style="width: 184px;height: 40px;border-right: #CCCCCC solid 1px;display: inline-block;vertical-align: top;line-height: 20px;text-align: center;font-size: 14px;">
                                                `+JsonDate["data"][i]["time"]+`<br>(`+JsonDate["data"][i]["weekday"]+`)
                                            </div>
                                            <div style="width: 120px;height: 40px;border-right: #CCCCCC solid 1px;display: inline-block;vertical-align: top;line-height: 40px;text-align: center;font-size: 14px;">
                                                `+JsonDate["data"][i]["one_line_work"][0]["day_type"]+`
                                            </div>
                                            <div style="width: 240px;height: 40px;border-right: #CCCCCC solid 1px;display: inline-block;vertical-align: top;line-height: 20px;text-align: center;font-size: 14px;">
                                                <p style="font-size: 12px;">`+JsonDate["data"][i]["one_line_work"][0]["name"]+`(`+JsonDate["data"][i]["one_line_work"][0]["job_number"]+`)<br>`+JsonDate["data"][i]["one_line_work"][0]["mobile"]+`</p>
                                            </div>
                                            <div style="width: 240px;height: 40px;display: inline-block;vertical-align: top;line-height: 40px;text-align: center;font-size: 14px;">
                                                `+JsonDate["data"][i]["second_line_work"]["name"]+`(`+JsonDate["data"][i]["second_line_work"]["job_number"]+`)
                                            </div>
                                        </div>
                                    `
                                }else {
                                    html_str = `
                                        <div class="scheduling-data" style="height: 80px;">
                                            <div style="width: 184px;height: 80px;border-right: #CCCCCC solid 1px;display: inline-block;vertical-align: top;text-align: center;font-size: 14px;">
                                                <div style="width: 184px;height: 40px;line-height: 20px;margin-top: 20px;">
                                                    `+JsonDate["data"][i]["time"]+`<br>(`+JsonDate["data"][i]["weekday"]+`)
                                                </div>
                                            </div>
                                            <div style="height: 80px;display: inline-block;vertical-align: top;font-size: 14px;">
                                                <div style="width: 100%;border-bottom: #CCCCCC solid 1px;font-size: 0;margin: 0;padding: 0;">
                                                    <div style="width: 120px;height: 40px;border-right: #CCCCCC solid 1px;display: inline-block;vertical-align: top;line-height: 40px;text-align: center;font-size: 14px;">
                                                        `+JsonDate["data"][i]["one_line_work"][0]["day_type"]+`
                                                    </div>
                                                    <div style="width: 240px;height: 40px;border-right: #CCCCCC solid 1px;display: inline-block;vertical-align: top;line-height: 20px;text-align: center;">
                                                        <p style="font-size: 12px;">`+JsonDate["data"][i]["one_line_work"][0]["name"]+`(`+JsonDate["data"][i]["one_line_work"][0]["job_number"]+`)<br>`+JsonDate["data"][i]["one_line_work"][0]["mobile"]+`</p>
                                                    </div>
                                                </div>
                                                <div style="width: 100%;font-size: 0;margin: 0;padding: 0;">
                                                    <div style="width: 120px;height: 40px;border-right: #CCCCCC solid 1px;display: inline-block;vertical-align: top;line-height: 40px;text-align: center;font-size: 14px;">
                                                        `+JsonDate["data"][i]["one_line_work"][1]["day_type"]+`
                                                    </div>
                                                    <div style="width: 240px;height: 40px;border-right: #CCCCCC solid 1px;display: inline-block;vertical-align: top;line-height: 20px;text-align: center;font-size: 14px;">
                                                        <p style="font-size: 12px;">`+JsonDate["data"][i]["one_line_work"][1]["name"]+`(`+JsonDate["data"][i]["one_line_work"][1]["job_number"]+`)<br>`+JsonDate["data"][i]["one_line_work"][1]["mobile"]+`</p>
                                                    </div>
                                                </div>
                                            </div>
                                            <div style="height: 80px;display: inline-block;vertical-align: top;font-size: 14px;">
                                                <div style="width: 240px;height: 80px;display: inline-block;vertical-align: top;line-height: 80px;text-align: center;">
                                                    `+JsonDate["data"][i]["second_line_work"]["name"]+`(`+JsonDate["data"][i]["second_line_work"]["job_number"]+`)
                                                </div>
                                            </div>
                                        </div>
                                    `
                                }
                                $("#SchedulingData").append(html_str)
                            }
                        }else {
                              alert(JsonDate["message"]);
                              window.location.reload();
                        }
                        document.getElementById("loading").style.display = "none";
                    }
                }
            };
        }

        function save_val(ids) {
            var job_number = $("#conferee").val()
            if (!job_number){
                alert("请选择人员！")
                return false
            }
            job_number = job_number.match(/\(([^)]*)\)/)[1];

            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/personnel/change_scheduling", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("id="+ids+"&job_number="+job_number);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);

                        if (JsonDate['code'] === 200) {
                            alert("修改成功！");
                            window.location.reload();
                        } else {
                            alert(JsonDate['message'])
                        }
                    }
                }
            };
        }
    </script>
{% endblock %}